﻿// -------------------------------------------------------------------------
//    @FileName         :    NFGlobalMiscData.cpp
//    @Author           :    gaoyi
//    @Date             :    24-8-22
//    @Email            :    445267987@qq.com
//    @Module           :    NFGlobalMiscData
//
// -------------------------------------------------------------------------

#include "NFGlobalMiscData.h"

NFGlobalMiscData::NFGlobalMiscData()
{
    if (EN_OBJ_MODE_INIT == NFShmMgr::Instance()->GetCreateMode())
    {
        CreateInit();
    }
    else
    {
        ResumeInit();
    }
}

NFGlobalMiscData::~NFGlobalMiscData()
{
}

int NFGlobalMiscData::CreateInit()
{
    return 0;
}

int NFGlobalMiscData::ResumeInit()
{
    return 0;
}

int NFGlobalMiscData::AfterAllConnectAndAllDescStore(NF_SERVER_TYPE serverType)
{
    if (serverType != NF_ST_LOGIC_SERVER) return 0;

    if (EN_OBJ_MODE_INIT == NFShmMgr::Instance()->GetRunMode())
    {
        Load(NF_ST_LOGIC_SERVER);
    }
    return 0;
}

int NFGlobalMiscData::LoadFromDB(const proto_ff::tbGlobalMiscData &dbData)
{
    m_stData.FromPb(dbData);
    return 0;
}

int NFGlobalMiscData::SaveToDB(proto_ff::tbGlobalMiscData &dbData)
{
    m_stData.ToPb(&dbData);
    return 0;
}

int NFGlobalMiscData::InitConfig()
{
    m_stData.id = GetDbId();
    m_stData.body.prof_count.resize(m_stData.body.prof_count.max_size());
    m_stData.body.photo_face_data.photo_face_array.resize(m_stData.body.photo_face_data.photo_face_array.max_size());
    for(int i = 0; i < (int)m_stData.body.photo_face_data.photo_face_array.size(); i++)
    {
        m_stData.body.photo_face_data.photo_face_array[i].index = -1;
    }
    MarkDirty();
    return 0;
}

int NFGlobalMiscData::GetDbId()
{
    return 1;
}
